<template id="submit">
  <!-- <popup v-model="show" height="80%"> -->
  <div>
    <img :src="user.avatar" style="width: 40px; height: 40px; border-radius: 50%;">
    <div v-text="user.name"></div>
    <popup v-model="show" class="popup">
      <group style="width: 90%; margin: 0 5% 10px;">
        <x-textarea v-model="post.content" placeholder="请输入异常问题" :max="max"></x-textarea>
        <x-button type="primary" action-type="button" @click.native="submit">提交</x-button>
        <x-button type="primary" action-type="button" @click.native="toCurrent">返回</x-button>
      </group>
      <div @click="submit" class="submit-btn">提交</div>
    </popup>
  </div>

  <!-- </popup> -->
</template>

<script>
  var submit = {
    template: '#submit',
    components: {
      popup: vuxPopup,
      group: vuxGroup,
      xTextarea: vuxXTextarea,
      xButton: vuxXButton,
    },
    data: function() {
      return {
        show: false,
        max: 140,
        post: {
          content: ''
        },
        user: {}
      }
    },
    methods: {
      submit: function() {
        var _this = this
        axios.post('post_report_content', JSON.stringify(this.post))
          .then(function(res) {
            _this.$vux.alert.show({
              title: '异常处理',
              content: res.data.callback,
              // onShow: function() {
              //   console.log('Plugin: I\'m showing')
              // },
              // onHide: function() {
              //   console.log('Plugin: I\'m hiding')
              // }
            })

          })
      },
      toCurrent: function() {
        this.$router.push('/')
      }
    },
    beforeCreate: function() {
      var _this = this
      axios.get('get_user')
        .then(function(res) {
          console.log(res.data)
          _this.user = res.data
        })
    }
  }
</script>
